package uebung12.orienteering;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

import uebung12.orienteering.exceptions.InvalidAreaException;
import uebung12.orienteering.exceptions.InvalidStartpointException;

public class Tests {

	char[][] simpleArea = new char[][] { { '#', '~', '~', '0', '0', '#' },
			{ '0', '^', '^', '0', '^', '~' }, { '0', '0', '^', '0', '0', '0' },
			{ '0', '0', '#', '^', '#', '0' }, { '~', '~', '0', '^', '^', '0' },
			{ '0', '~', '0', '0', '0', '0' }, };
	char[][] shortcutArea = new char[][] { { '#', '~', '~', '0', '0', '#' },
			{ '0', '^', '^', '0', '^', '~' }, { '0', '0', '0', '0', '0', '0' },
			{ '0', '0', '#', '^', '#', '0' }, { '~', '~', '0', '^', '^', '0' },
			{ '0', '~', '0', '0', '0', '0' }, };
	public Orienteering simpleMap, shortcutMap;

	@Before
	public void init() {
		try {
			simpleMap = new Orienteering(simpleArea);
			shortcutMap = new Orienteering(shortcutArea);
		} catch (InvalidAreaException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	@Test
	public void simpleCheck() {
		assertTrue("toString seems ok", ("#~~00#\n" + "0^^0^~\n" + "00^000\n"
				+ "00#^#0\n" + "~~0^^0\n" + "0~0000\n").equals(simpleMap.toString()));
	}

	@Test
	public void shortcutCheck() {
		try {
			assertTrue("Shortcut was taken successfully",
					9 == shortcutMap.analyzeCosts(0, 0)[0][5]);
			shortcutMap.analyzeCosts(2, 2);
		} catch (InvalidStartpointException e) {
			assertTrue("Correct Exception caught.", true);
		}
	}

}
